home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Panel Editor / Source / PanelEditorUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-08  |  3.7 KB  |  172 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PanelEditorUtils.h
  3.  
  4.     Contains:    PanelEditor utility functions & classes
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1994,95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11.  
  12. #ifndef _PANELEDITORUTILS_
  13. #define _PANELEDITORUTILS_
  14.  
  15. // --- OpenDoc Includes ---
  16.  
  17. #ifndef _ODTYPES_
  18. #include <ODTypes.h>
  19. #endif
  20.  
  21. // --- OpenDoc Utilities ---
  22.  
  23. #ifndef _ITEXT_
  24. #include <IText.h>
  25. #endif
  26.  
  27. #ifndef _ODDEBUG_
  28. #include <ODDebug.h>
  29. #endif
  30.  
  31. #ifndef _ODUTILS_
  32. #include <ODUtils.h>
  33. #endif
  34.  
  35. // --- Macintosh Includes ---
  36.  
  37. #ifndef __TYPES__
  38. #include <Types.h>
  39. #endif
  40.  
  41. #ifndef __TYPES__
  42. #include <Types.h>
  43. #endif
  44.  
  45. //------------------------------------------------------------------------------
  46. // Typedefs
  47. //------------------------------------------------------------------------------
  48.  
  49. typedef struct ScrollDataRec {
  50.     ODFrame*        frame;
  51.     Environment*    ev;
  52. } ScrollDataRec;
  53.  
  54. //------------------------------------------------------------------------------
  55. // Utility Class Definitions
  56. //------------------------------------------------------------------------------
  57.  
  58. class CFrameProxy // (aka CFuton)
  59. {
  60.     public:
  61.     CFrameProxy();
  62.     ~CFrameProxy();
  63.     
  64.     void        InitFrameProxy(ODID frameID, ODDraft* draft);
  65.     void        InitFrameProxy(Environment* ev, ODFrame* frame);
  66.     void        Purge(Environment* ev);
  67.  
  68.     ODFrame*    GetFrame(Environment* ev);
  69.     void        SetFrame(Environment* ev, ODFrame* frame);
  70.     ODBoolean    FrameIsLoaded(Environment* ev);
  71.     ODID        GetID();
  72.     ODDraft*    GetDraft();
  73.     
  74.     private:
  75.     ODFrame*    fFrame;
  76.     ODID        fID;
  77.     ODDraft*    fDraft;
  78. };
  79.  
  80. class CDrawingText
  81. {
  82.     public:
  83.     CDrawingText();
  84.     CDrawingText(ODIText* text);
  85.     ~CDrawingText();
  86.  
  87.     private:
  88.     GrafPtr    port;
  89.     short    font;
  90.     Style    face;
  91.     short    size;
  92. };
  93.  
  94. //------------------------------------------------------------------------------
  95. // Function Prototypes
  96. //------------------------------------------------------------------------------
  97.  
  98. ODIText*        GetPartName(Environment* ev, ODPart* part, ODType category);
  99. ODBoolean        NamesAreEquivalent(Environment* ev, ODIText* fileName,
  100.                                         ODIText* partName);
  101. void            GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
  102.                                         ODLangCode* language);
  103. void            GetScriptFontSize(Environment* ev, ODScriptCode script,
  104.                                         ODSShort* fontNum, ODUShort* fontSize);
  105.  
  106. void            FixedToIntRect(ODRect& fixedRect, Rect& intRect);
  107. void            IntToFixedRect(Rect& intRect, ODRect& fixedRect);
  108.  
  109. void            LoadThumbnail(Environment* ev, Handle* thumbnail);
  110.  
  111. Rect            TilePartWindow(Environment* ev, Rect* facetBounds,
  112.                                         Rect* partWindowBounds);
  113.  
  114. ODUShort        CountFramesFacets(Environment* ev, ODFrame* frame);
  115. void            RemoveFacetsFromFrame(Environment* ev, ODFrame* frame);
  116.  
  117. void            GetQDFrameBounds(Environment* ev, ODFrame* frame, Rect* bounds);
  118.     
  119. extern pascal    void ScrollProc(ControlHandle control, short partCode);
  120.                             
  121.                                 
  122.  
  123. //-------------------------------------------------------------------------
  124. // Inline methods
  125. //-------------------------------------------------------------------------
  126.  
  127. //=========================================================================
  128. // CFrameProxy
  129. //=========================================================================
  130.  
  131. inline CFrameProxy::CFrameProxy()
  132. {
  133.     fFrame = kODNULL;
  134.     fID = kODNULLID;
  135.     fDraft = kODNULL;
  136. }
  137.     
  138. inline CFrameProxy::~CFrameProxy()
  139. {
  140.     ODSafeReleaseObject(fFrame);
  141. }
  142.     
  143. inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
  144. {
  145.     ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
  146.     
  147.     fFrame = kODNULL;
  148.     fID = frameID;
  149.     fDraft = draft;
  150. }
  151.     
  152. inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
  153. {
  154.     ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
  155.     
  156.     this->SetFrame(ev,frame);
  157. }
  158.  
  159. inline ODID CFrameProxy::GetID()
  160. {
  161.     return fID;
  162. }
  163.  
  164. inline ODDraft* CFrameProxy::GetDraft()
  165. {
  166.     return fDraft;
  167. }
  168.  
  169.  
  170. #endif
  171.  
  172.